How to force-shutdown your computer avoiding data loss in Linux

 

Sometimes you can have your computer frozen and you need to force-shutdown it, but this is very dangerous, so here are some tips about how to do it in the correct way:

The first, is to access to the console since your desktop is unresponsive, login on it from your user and you can proceed:

Restart your desktop

If what is blocked is your desktop (E17 and newer versions) you can try to restart it by sending a fake segfault to it:

kill -s SEGV $( pidof enlightenment )

It will make the desktop launcher (enlightenment_start) think that the desktop crashed and will restart it maintaining your apps opened, so this is the first thing to try.

sorry, not possible in e16 as enlightenment_start does not exist

Crash your entire desktop

You can try to send a force-kill signal to your desktop like:

killall -9 e16

Or you can try to restart your login manager too, but the first option is more reliable:

sudo service lightdm restart

Force-shutdown (safe mode) your computer

You can first try to run Ctrl Alt Del from the console to see if the computer simply reboots

If you have no way to recover your desktop, for example if your computer is entirely unresponsive, you can trigger the magic kernel keys to force a shutdown, this combination is:

note: PrtScr is also called Imp Pt in Latin keyboards